<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
	String path = request.getContextPath();
%>
<head>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/icon.css">
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/locale/easyui-lang-zh_CN.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	$(function(){
	
		$("#resetBtn").bind("click", function() {
			$('#form').form('clear');
		});
		
		
  $("#uptBtn").bind('click',function(){
			  
				 
				    $.ajax({
			            //几个参数需要注意一下
			                type: "POST",//方法类型
			                dataType: "json",//预期服务器返回的数据类型
			                url: "<%=path%>/userAction/pwdupt",
			                data: $('#form').serialize(),
			                success: function (result) {
			                	
			                	if(result.errMsg!=null){
			                		$.messager.alert('提示',result.errMsg); 
			                	}else{
			                		$.messager.confirm('提示',result.msg,function(r){    
			                	    	window.location.href="<%=path%>/userAction/login";    
			                	});  
			                	}
			                	
			                
			                	
			                },
			                error : function() {
			                    alert("系统异常！");
			                }
			            });
			  
      });
		
  
  //修改邮箱
  $("#emailUptBtn").bind('click',function(){
	  
		 
	    $.ajax({
          //几个参数需要注意一下
              type: "POST",//方法类型
              dataType: "json",//预期服务器返回的数据类型
              url: "<%=path%>/userAction/emailupt",
              data: $('#form1').serialize(),
              success: function (result) {
              	
              	if(result.errMsg!=null){
              		$.messager.alert('提示',result.errMsg); 
              	}else{
              		$.messager.confirm('提示',result.msg,function(r){    
              	    	window.location.href="<%=path%>/views/user/main.jsp";    
              	});  
              	}
              	
              
              	
              },
              error : function() {
                  alert("系统异常！");
              }
          });

});
  
  
  
  
	})
	
	//发送验证码
	function sendEmailCode(){
		var email=$("#email").val();
		var dataParm={"email":email};
	    $.ajax({
            //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "<%=path%>/userAction/sendEmailCode?type=uptemail",
                data: dataParm,
                success: function (result) {
                	if(result.errMsg!=null && result.errMsg!=""){
                		$.messager.alert('提示',result.errMsg);  
                	}
                },
                error : function() {
                    alert("系统异常！");
                }
            });
	}
	
</script>

</head>
<body class="easyui-layout" >
	<div  style="width:350px;margin-top: 0px;margin-left: 550px;">
		<form id="form" method="post" class="easyui-form">
		<h3 style="margin-left: 100px;">修改密码</h3>
			<div >
				<label>原&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;码:</label> <input style="width: 150px;" class="easyui-textbox" type="text"
					name="repassword" />
			</div>
			<div style="margin-top: 10px;">
				<label>新&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</label> <input class="easyui-textbox" style="width: 150px;" type="text"
					name="password"/>
			</div>
			
			<div id="btn" style="margin-top: 20px;">
				<a id="uptBtn" class="easyui-linkbutton"
					 style="width: 100px;">修改</a>
			</div>
		</form>
		<br><hr>
			<form id="form1" method="post" class="easyui-form">
		<h3 style="margin-left: 100px;">修改邮箱</h3>
		
			<div style="margin-top: 10px;">
							<label>邮箱:</label> <input id="email" type="text" style="width: 150px;height: 30px;" name="email" value="${userInfo.email}"
								class="easyui-textbox" required="required" validType="email"> </input>
								<button onclick="sendEmailCode();">发送验证码</button>
			</div>
			
			<div style="margin-top: 10px;">
							<label>验证码:</label> <input id="dd" type="text" name="code"
								class="easyui-textbox" style="width: 150px;" required="required"> </input>
			</div>
			
			<div id="btn" style="margin-top: 20px;">
				<a id="emailUptBtn" class="easyui-linkbutton"
					 style="width: 100px; ">修改</a>
			</div>
		</form>
	</div>
</body>
</html>